import DropdownAlert, {DropdownAlertType} from 'react-native-dropdownalert';

interface Params {
  type?: DropdownAlertType;
  title?: string;
  message: string;
  payload?: object;
  interval?: number;
}

export class ToastManger {
  static dropDownAlertRef: DropdownAlert;

  public static setDropDownAlertRef(dropDownAlertRef: DropdownAlert) {
    this.dropDownAlertRef = dropDownAlertRef;
  }

  public static displayAlert({
    type = 'error',
    title = '',
    message,
    payload,
    interval,
  }: Params) {
    this.dropDownAlertRef?.alertWithType(
      type,
      title,
      message,
      payload,
      interval,
    );
  }
}
